package com.goktech.sportsmall.controller;

import com.goktech.sportsmall.bean.AddressBean;
import com.goktech.sportsmall.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/address")
public class VueAddressController {

    @Autowired(required = false)
    private AddressService addressService;

    // 查询地址信息
    @RequestMapping(value = "/select",method = RequestMethod.GET)
    public Map<String,Object> selectAddress(){
        return addressService.selectAddress();
    }

    // 添加信息
    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> insertAddress(AddressBean addressBean) {
        return addressService.insertAddress(addressBean);
    }
    // 添加信息
    @RequestMapping(value = "/insert",method = RequestMethod.GET)
    public Map<String,Object> insertAddressGet(AddressBean addressBean) {
        return addressService.insertAddress(addressBean);
    }

    // 删除地址
    @RequestMapping(value = "/del",method = RequestMethod.DELETE)
    public Map<String,Object> deleteAddress(int a_id){
        return addressService.deleteAddress(a_id);
    }
    // 删除地址 get
    @RequestMapping(value = "/del",method = RequestMethod.GET)
    public Map<String,Object> deleteAddressGet(int a_id){
        return addressService.deleteAddress(a_id);
    }
    // 修改地址
    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    public Map<String,Object> updateAddress(AddressBean addressBean){
        return addressService.updateAddress(addressBean);
    }
    // 修改地址
    @RequestMapping(value = "/update",method = RequestMethod.GET)
    public Map<String,Object> updateAddressGet(AddressBean addressBean){
        return addressService.updateAddress(addressBean);
    }
}
